/**
  ******************************************************************************
  * @file    bsp.c 
  * @author  Iron
  * @date    2022-01-01
  * @version v1.0
  * @brief   bsp c file
  */

/** @addtogroup GROUP_TEMPLATE
  * @{
  */ 

/* Private includes ----------------------------------------------------------*/
#include <stdio.h>
#include "bsp.h"
#include "bsp_led.h"
#include "bsp_uart.h"

/* Private define ------------------------------------------------------------*/
#define PRINTF_UART_ID  BSP_UART0

/* Private macro -------------------------------------------------------------*/
/* Private typedef -----------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/

// In IAR the function \c putchar must be overridden.
// Override 'putchar' function in order to use printf() to output to UART.
#ifdef __ICCARM__
int putchar(int data)
#else
int stdout_putchar(int data, FILE *stdio)	// __GNUC__
#endif
{
    uint8_t tmp = data;
    bsp_uart_poll_tx(PRINTF_UART_ID, &tmp, 1, 0);
    return data;
}

/**
  Get a character from stdin
 
  \return     The next character from the input, or -1 on read error.
*/
int stdin_getchar (void) {
  // ...
  return (-1);
}

int32_t bsp_init(void)
{
    bsp_led_init();
    bsp_uart_init();    // serial_line_input_byte
    
    
//    bsp_timer_init();

    return 0;
}


/**
  * @}
  */

/******************* (C)COPYRIGHT 2022 ***** END OF FILE *********************/
